#include <iostream>
#include <map>
#include <algorithm>
#define ll long long

using namespace std;


int gcd(int a,int b){
	return b == 0 ? a : gcd(b,a % b);
}

//78%
int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n,m;
	cin >> n >> m;
	
	pair<int,int> arr[m];
	
	for(int i = 0; i < m; ++i){
		cin >> arr[i].first >> arr[i].second;
	}
	
	int sum = 0;
	
	for(int i = 1; i <= n ; i++){
		int maxi = -1;
		map<pair<int,int>,int> mp;
		for(int j = 0; j < m ; j++){
			int y = arr[j].second;
			int x = arr[j].first - i;
			pair<int,int> key;
			if(x == 0){
				key = {0,0};
			}else{
				int num = gcd(abs(y),abs(x));
				key = {y/num , x/num};
			}
			mp[key]++;
			if(mp[key] > maxi){
				maxi = mp[key];
			}
		}
		sum += maxi;
	}
	
	cout << sum;
	
	return 0;
}
